package com.erlin.platform.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.io.Serializable;

import com.erlin.platform.constant.user.UserRoleEnum;
import com.erlin.platform.constant.user.UserStatus;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;

/**
 * <p>
 * 后台用户表
 * </p>
 *
 * @author alin
 * @since 2021-05-16
 */
@Data
@EqualsAndHashCode(callSuper = false)
public class ElUser implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    private String username;

    private String password;

    /**
     * 头像
     */
    private String icon;

    /**
     * 邮箱
     */
    private String email;

    /**
     * 昵称
     */
    private String nickName;

    /**
     * 备注信息
     */
    private String note;

    /**
     * 创建时间
     */
    private LocalDateTime createTime;

    /**
     * 最后登录时间
     */
    private LocalDateTime loginTime;

    /**
     * 帐号启用状态：0->禁用；1->启用
     */
    private Integer status;
    /**
     * 电话号码
     */
    private String phoneNum;
    /**
     * 微信openId
     */
    private String openId;
    /**
     * 用户类别  ADMIN,CUSTOMER,BUSINESSMAN
     */
    private String userClas;


    public void init() {
        this.setStatus(UserStatus.NORMAL);
        if(StringUtils.isEmpty(userClas)){
            this.userClas = UserRoleEnum.CUSTOMER.toString();
        }
        if(StringUtils.isEmpty(nickName)){
            this.nickName = "微信用户"+phoneNum;
        }
    }
}
